/*     */ package com.cr.common.utils.spring;
/*     */ 
/*     */ import com.cr.common.utils.MyStringUtils;
/*     */ import org.springframework.aop.framework.AopContext;
/*     */ import org.springframework.beans.BeansException;
/*     */ import org.springframework.beans.factory.NoSuchBeanDefinitionException;
/*     */ import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
/*     */ import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
/*     */ import org.springframework.context.ApplicationContext;
/*     */ import org.springframework.context.ApplicationContextAware;
/*     */ import org.springframework.stereotype.Component;
/*     */ 
/*     */ @Component
          @SuppressWarnings("unchecked")
/*     */ public final class SpringUtils implements BeanFactoryPostProcessor, ApplicationContextAware {
/*     */   private static ConfigurableListableBeanFactory beanFactory;
/*     */   
/*     */   private static ApplicationContext applicationContext;
/*     */   
/*     */   public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
/*  29 */     SpringUtils.beanFactory = beanFactory;
/*     */   }
/*     */   
/*     */   public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
/*  35 */     SpringUtils.applicationContext = applicationContext;
/*     */   }
/*     */   
/*     */   public static <T> T getBean(String name) throws BeansException {
/*  49 */     return (T)beanFactory.getBean(name);
/*     */   }
/*     */   
/*     */   public static <T> T getBean(Class<T> clz) throws BeansException {
/*  62 */     T result = (T)beanFactory.getBean(clz);
/*  63 */     return result;
/*     */   }
/*     */   
/*     */   public static boolean containsBean(String name) {
/*  74 */     return beanFactory.containsBean(name);
/*     */   }
/*     */   
/*     */   public static boolean isSingleton(String name) throws NoSuchBeanDefinitionException {
/*  87 */     return beanFactory.isSingleton(name);
/*     */   }
/*     */   
/*     */   public static Class<?> getType(String name) throws NoSuchBeanDefinitionException {
/*  98 */     return beanFactory.getType(name);
/*     */   }
/*     */   
/*     */   public static String[] getAliases(String name) throws NoSuchBeanDefinitionException {
/* 111 */     return beanFactory.getAliases(name);
/*     */   }
/*     */   
/*     */   public static <T> T getAopProxy(T invoker) {
/* 123 */     return (T)AopContext.currentProxy();
/*     */   }
/*     */   
/*     */   public static String[] getActiveProfiles() {
/* 133 */     return applicationContext.getEnvironment().getActiveProfiles();
/*     */   }
/*     */   
/*     */   public static String getActiveProfile() {
/* 143 */     String[] activeProfiles = getActiveProfiles();
/* 144 */     return MyStringUtils.isNotEmpty((Object[])activeProfiles) ? activeProfiles[0] : null;
/*     */   }
/*     */ }


/* Location:              D:\tmp\creditorRights-admin\BOOT-INF\lib\creditorRights-common-4.7.0.jar!\com\cr\commo\\utils\spring\SpringUtils.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.1.3
 */